var express = require('express');
var router = express.Router();
var des = require('./des.js');
var sign = require('./sign.js');
/* GET home page. */
router.get('/', function(req, res) {
  // res.render('login', { title: 'Express' });
  res.render('login');
});

router.post('/',function(req,res){
	var data =req.body;
	delete data.vcode;
	data.password=des.strDec(data.password,1,2,3).split(',')[1];
	sign.loginDataReq(req,data,'/login',"post",function(ResData){
		if(ResData!=""){
			
			req.session.user=data.name;    //用户名
			delete req.session.vcode;           
		    req.session.token=ResData.token
		  
			res.send(ResData);
		}
	});

})

module.exports = router;
